﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.WindowsAzure;
using Microsoft.WindowsAzure.StorageClient;


namespace MyCloudHelpers
{
    public static class QueueHelper
    {
        public static CloudQueueClient queueStorage;
       
        public static void AppStart()
        {
            try
            {

                var storageAccount = CloudStorageAccount.FromConfigurationSetting("DataConnectionString");

                queueStorage = storageAccount.CreateCloudQueueClient();
                CloudQueue queue = queueStorage.GetQueueReference("TweetsToSearch");
               
                queue.CreateIfNotExist();
            }
            catch (Exception)
            {
                // display a nice error message if the local development storage tool is not running or if there is 
                // an error in the account configuration that causes this exception
                throw new Exception("The Windows Azure storage services cannot be contacted " +
                     "via the current account configuration or the local development storage tool is not running. " +
                     "Please start the development storage tool if you run the service locally!");
            }

        }
    }
}
